package heima3_2.cn.osc.hold;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import net.oschina.app.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;
import heima3_2.cn.osc.base.BaseHolder;
import heima3_2.cn.osc.base.MyBaseAdapter;
import heima3_2.cn.osc.model.bean.MessagesBean;
import heima3_2.cn.osc.utils.Global;

/**
 * Created by yaozhanlie on 2017/1/18.
 */

public class LeaveHolder extends BaseHolder<MessagesBean.MessageBean> {

    @Bind(R.id.civ_left_photo)
    CircleImageView mCivLeftPhoto;
    @Bind(R.id.tv_left_name)
    TextView mTvLeftName;
    @Bind(R.id.tv_left_words)
    TextView mTvLeftWords;
    @Bind(R.id.tv_left_time)
    TextView mTvLeftTime;
//    @Bind(R.id.tv_left_count)
    TextView mTvLeftCount;
    @Bind(R.id.leave_item)
    RelativeLayout mLeaveItem;

    public LeaveHolder(Context context, ViewGroup parent, MyBaseAdapter<MessagesBean.MessageBean> adapter, int position, MessagesBean.MessageBean bean) {
        super(context, parent, adapter, position, bean);
    }

    @Override
    public View onCreateView(Context context, ViewGroup parent, int position, MessagesBean.MessageBean bean) {
        View view = Global.inflats(R.layout.item_msg_left);
        ButterKnife.bind(this, view);
        mTvLeftCount= (TextView) view.findViewById(R.id.tv_left_count);
        return view;
    }

    @Override
    protected void onRefreshView(MessagesBean.MessageBean bean, int position) {
        mTvLeftName.setText(bean.getFriendname());
        mTvLeftWords.setText(bean.getContent());
        mTvLeftTime.setText(bean.getPubDate());
//        mTvLeftCount.setText(bean.getMessageCount());
        Picasso.with(context).load(bean.getPortrait()).resize(50, 50).centerCrop().into(mCivLeftPhoto);
    }

    @OnClick({R.id.civ_left_photo, R.id.leave_item})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.civ_left_photo:
                Global.showToast("进入用户中心");
                break;
            case R.id.leave_item:
                Global.showToast("进入动弹详情");
                break;
        }
    }
}
